import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sports_new/controller/service/config_service.dart';
import 'package:sports_new/resources/colours.dart';
import 'package:sports_new/resources/styles.dart';
import 'package:sports_new/utils/widget_utils.dart';
import 'package:sports_new/widgets/base/qkd_widget.dart';

import '../../../widgets/base/qkd_text.dart';

class ZqOddsTypePage extends StatefulWidget {
  const ZqOddsTypePage({super.key});

  @override
  State<ZqOddsTypePage> createState() => _ZqOddsTypePageState();
}

class _ZqOddsTypePageState extends State<ZqOddsTypePage> {
  ZqConfig config = Get.find<ConfigService>().zqConfig;
  ConfigService configService = Get.find<ConfigService>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: Styles.appBar(title: QkdText('足球指数类型')),
      backgroundColor: Colours.scaffoldBg,
      body: ListView(children: [
        SizedBox(height: 10),
        Styles.card(
            margin: EdgeInsets.symmetric(horizontal: 8),
            child: Column(
              children: [
                cell(0),
                QkdWidget.seperateLine(),
                cell(1),
                QkdWidget.seperateLine(),
                cell(2)
              ],
            ))
      ]),
    );
  }

  Widget cell(int index) {
    return QkdWidget.selectCell(
        configService.zqOddsType[index], config.zqList7.contains(index),
        onTap: () {
      if (config.zqList7.contains(index)) {
        config.zqList7.remove(index);
      } else {
        config.zqList7.add(index);
      }
      config.zqList7.sort((a, b) => a.compareTo(b));
      update();
      configService.update(ConfigType.zqList7, config.zqList7);
    });
  }
}
